// WITH_STDLIB
// ISSUE: KT-82177
// DO_NOT_CHECK_NON_PSI_SYMBOL_RESTORE
// DO_NOT_CHECK_SYMBOL_RESTORE_K1
// LANGUAGE: +AllowContractsOnPropertyAccessors, +ContextParameters

@file:OptIn(ExperimentalContracts::class)

import kotlin.contracts.*

var Int?.prop: Int?
    get() {
        contract { returns() implies (this@prop != null) }
        return null
    }
    set(v: Int?) {
        contract {
            returns() implies (v != null)
            returns() implies (this@prop != null)
        }
    }

sealed class Status {
    class Ok : Status() {}
    class Error(val message: String) : Status()
}

val Status.isError: Boolean
    get() {
        contract { returns(true) implies (this@isError is Status.Error) }
        return this is Status.Error
    }

context(s: Status)
val isContextError: Boolean
    get() {
        contract { returns(true) implies (s is Status.Error) }
        return s is Status.Error
    }
